﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:local="clr-namespace:WP7iPhone"
    xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:im="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions" xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" 
    x:Class="WP7iPhone.Page1"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    shell:SystemTray.IsVisible="True">
    <phone:PhoneApplicationPage.FontFamily>
        <StaticResource ResourceKey="PhoneFontFamilyNormal"/>
    </phone:PhoneApplicationPage.FontFamily>
    <phone:PhoneApplicationPage.FontSize>
        <StaticResource ResourceKey="PhoneFontSizeNormal"/>
    </phone:PhoneApplicationPage.FontSize>
    <phone:PhoneApplicationPage.Foreground>
        <StaticResource ResourceKey="PhoneForegroundBrush"/>
    </phone:PhoneApplicationPage.Foreground>

    
    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent"
                    MouseLeftButtonDown="image_MouseLeftButtonDown" 
                    MouseLeftButtonUp="image_MouseLeftButtonUp"
                    MouseMove="image_MouseMove" 
                     >
        <Grid.Resources>
                      
            <!--
            Data converter for the nav panel fill color
            -->
            <local:NavColorValueConverter x:Key="navFill"/>
        </Grid.Resources>

        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition />
            <RowDefinition Height="30"/>
            <RowDefinition Height="132"/>
        </Grid.RowDefinitions>

        <!-- Status Bar -->
        <StackPanel x:Name="StatusBar" Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Center">
            <TextBlock><Run Text="Status Bar"/></TextBlock>
        </StackPanel>
                
        <!-- Scrolling application icon view -->
        <ScrollViewer x:Name="scrollView" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled" Grid.Row="1" 
                      ManipulationCompleted="ScrollViewer_ManipulationCompleted"> 
            <ScrollViewer.Resources>
                <Storyboard x:Name="snapStoryboard">
                    <DoubleAnimation
                        x:Name="snapAnimation"
                        Storyboard.TargetName="Mediator"
                        Storyboard.TargetProperty="HorizontalOffset"
                        From="1.0" To="0.0" Duration="0:0:0.250">
                        <DoubleAnimation.EasingFunction>
                            <ExponentialEase Exponent="9" EasingMode="EaseOut"/>
                        </DoubleAnimation.EasingFunction>
                    </DoubleAnimation>
                </Storyboard>

            </ScrollViewer.Resources>
            <StackPanel x:Name="appPanel" Orientation="Horizontal" Background="Transparent" HorizontalAlignment="Center" VerticalAlignment="Center" Loaded="StackPanel_Loaded"
                      ManipulationDelta="ScrollViewer_ManipulationDelta">
                <StackPanel Orientation="Vertical" Width="480">
                    <TextBox x:Name="SearchInput"/>
                </StackPanel>
                <!-- 
                    Dynamically generated AppPageControls will be added here by the code-behind
                -->
            </StackPanel>
        </ScrollViewer>
        
        <!-- Mediator that forwards the property changes for the scroll view -->
        <local:ScrollViewerOffsetMediator
            x:Name="Mediator"
            ScrollViewer="{Binding ElementName=scrollView}"/>

        <!-- Navigation crumb bar -->
        <StackPanel x:Name="navPanel" 
                    Grid.Row="2" 
                    Orientation="Horizontal"
                    HorizontalAlignment="Center"
                    DataContext="{Binding ElementName=Mediator}">
            <Canvas Height="14" Width="14" Margin="3">
                <Line
                    X1="6" Y1="6"
                    X2="12" Y2="12"
                    Stroke="White"
                    StrokeThickness="2"
                    />
                <Ellipse Height="10" Width="10" Stroke="White" StrokeThickness="1" Canvas.Left="0" Canvas.Top="0"
                     Fill="{Binding HorizontalOffset, Converter={StaticResource navFill},ConverterParameter=0}"/>
            </Canvas>
            <Ellipse Height="14" Width="14" Stroke="White" StrokeThickness="1" Margin="0" 
                     Fill="{Binding HorizontalOffset, Converter={StaticResource navFill},ConverterParameter=1}"/>
            <Ellipse Height="14" Width="14" Stroke="White" StrokeThickness="1" Margin="3" 
                     Fill="{Binding HorizontalOffset, Converter={StaticResource navFill},ConverterParameter=2}"/>
        </StackPanel>

        <!-- Dock at the bottom -->
        <local:AppPageControl x:Name="Dock" Grid.Row="3" />
    </Grid>
</phone:PhoneApplicationPage>
